package Java.test;

import java.util.Random;
import java.util.Scanner;

//产生10个1-100的数，并找出最小的
public class ArrayTest2 {
    public static void main(String[] args) {
        int []arr=getArray();
        int min=getMin(arr);
        System.out.println("最小值："+min);
    }
    public static int[]getArray(){
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入数组长度：");
        int count=sc.nextInt();
        Random random=new Random();
        int[]arr=new int[count];
        for (int i=0;i< arr.length;i++){
            arr[i]=random.nextInt(100)+1;
            System.out.println(arr[i]);
        }
        return arr;
    }
    public static int getMin(int[]arr){
        int min=arr[0];
        for(int i=1;i< arr.length;i++){
            if (arr[i]<min){
                min=arr[i];
            }
        }
        return min;
    }

}
